home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Plotter / drawingFuncs.psw < prev    next >
Text File  |  1995-06-12  |  2KB  |  76 lines

  1. defineps loadPSProcedures()
  2.     /xpos 0 def
  3.     /ypos 0 def
  4.     /ticklength [8 2 2 2 2 5 2 2 2 2] def
  5.  
  6.     % x 
  7.     /getticklength {10 idiv 10 mod abs ticklength exch get} def
  8.  
  9.  
  10.     % x y length     
  11.     /vtick { moveto 0 exch rlineto stroke } def
  12.     /htick { moveto 0 rlineto stroke } def
  13.     
  14.     % x     
  15.     /increase-x {/xpos xpos 10 add def} def
  16.     /decrease-x {/xpos xpos 10 sub def} def
  17.  
  18.     % y     
  19.     /increase-y {/ypos ypos 10 add def} def
  20.     /decrease-y {/ypos ypos 10 sub def} def
  21. endps
  22.  
  23. defineps drawCircle(float x, y, radius)
  24.     % describe the path of a circle
  25.     newpath
  26.     x y radius 0 360 arc
  27.     closepath
  28.     stroke
  29. endps
  30.  
  31. defineps drawAxes(float x, y, width, height)
  32.     gsave
  33.         % set max and min of visible area
  34.         /xmax x width add 1 sub def
  35.         /ymax y height add def
  36.         /ymin y 1 add def
  37.         /xpos 0 def
  38.         /ypos 0 def
  39.  
  40.         % draw border
  41.         x ymin moveto
  42.         x ymax lineto
  43.         xmax ymax lineto
  44.         xmax ymin lineto
  45.         closepath
  46.         stroke
  47.  
  48.         % now draw axes
  49.         x 0 moveto
  50.         xmax 0 lineto
  51.         stroke
  52.         0 ymin moveto
  53.         0 ymax lineto
  54.         stroke
  55.         0 0 moveto
  56.         % draw the pos x ticks
  57.         {xpos xmax le
  58.             {xpos getticklength neg xpos 0 vtick increase-x}{exit} ifelse
  59.         } loop
  60.         % draw the neg x ticks
  61.         0 0 moveto
  62.         {xpos x ge
  63.             {xpos getticklength neg xpos 0 vtick decrease-x}{exit} ifelse
  64.         } loop
  65.         % draw the pos y ticks
  66.         0 0 moveto
  67.         {ypos ymax le
  68.             {ypos getticklength neg 0 ypos htick increase-y}{exit} ifelse
  69.         } loop
  70.         % draw the neg y ticks
  71.         0 0 moveto
  72.         {ypos ymin ge
  73.             {ypos getticklength neg 0 ypos htick decrease-y}{exit} ifelse
  74.         } loop
  75.     grestore
  76. endps